using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CatalogManager.CatalogForms
{
	/// <summary>
	/// Summary description for VendorSelector.
	/// </summary>
	public class VendorSelector : System.Windows.Forms.Form
	{
		public DataSet catLanguages = null;
		public DataSet Languages = null;
		public string CatalogName = null;

		private System.Windows.Forms.ListBox listBoxVendor;
		private System.Windows.Forms.Button btnVendorSelectorOk;
		private System.Windows.Forms.Button btnVendorSelectorCancel;
		private System.Windows.Forms.ComboBox comboBoxCtlgLanguages;
		private System.Windows.Forms.Label lblVendorSector;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public VendorSelector()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.listBoxVendor = new System.Windows.Forms.ListBox();
			this.lblVendorSector = new System.Windows.Forms.Label();
			this.btnVendorSelectorOk = new System.Windows.Forms.Button();
			this.btnVendorSelectorCancel = new System.Windows.Forms.Button();
			this.comboBoxCtlgLanguages = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// listBoxVendor
			// 
			this.listBoxVendor.Location = new System.Drawing.Point(8, 40);
			this.listBoxVendor.Name = "listBoxVendor";
			this.listBoxVendor.Size = new System.Drawing.Size(272, 160);
			this.listBoxVendor.TabIndex = 0;
			// 
			// lblVendorSector
			// 
			this.lblVendorSector.Location = new System.Drawing.Point(8, 16);
			this.lblVendorSector.Name = "lblVendorSector";
			this.lblVendorSector.Size = new System.Drawing.Size(100, 16);
			this.lblVendorSector.TabIndex = 1;
			this.lblVendorSector.Text = "Select a vendor";
			// 
			// btnVendorSelectorOk
			// 
			this.btnVendorSelectorOk.Location = new System.Drawing.Point(56, 240);
			this.btnVendorSelectorOk.Name = "btnVendorSelectorOk";
			this.btnVendorSelectorOk.TabIndex = 2;
			this.btnVendorSelectorOk.Text = "Ok";
			this.btnVendorSelectorOk.Click += new System.EventHandler(this.btnVendorSelectorOk_Click);
			// 
			// btnVendorSelectorCancel
			// 
			this.btnVendorSelectorCancel.Location = new System.Drawing.Point(152, 240);
			this.btnVendorSelectorCancel.Name = "btnVendorSelectorCancel";
			this.btnVendorSelectorCancel.TabIndex = 3;
			this.btnVendorSelectorCancel.Text = "Cancel";
			this.btnVendorSelectorCancel.Click += new System.EventHandler(this.btnVendorSelectorCancel_Click);
			// 
			// comboBoxCtlgLanguages
			// 
			this.comboBoxCtlgLanguages.Location = new System.Drawing.Point(8, 208);
			this.comboBoxCtlgLanguages.Name = "comboBoxCtlgLanguages";
			this.comboBoxCtlgLanguages.Size = new System.Drawing.Size(272, 21);
			this.comboBoxCtlgLanguages.TabIndex = 4;
			// 
			// VendorSelector
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(286, 270);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.comboBoxCtlgLanguages,
																		  this.btnVendorSelectorCancel,
																		  this.btnVendorSelectorOk,
																		  this.lblVendorSector,
																		  this.listBoxVendor});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "VendorSelector";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "VendorSelector";
			this.Load += new System.EventHandler(this.VendorSelector_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void VendorSelector_Load(object sender, System.EventArgs e)
		{
			// load the languages
			if(catLanguages!=null)
			{
				if(catLanguages.Tables[0].Rows.Count>=1)
				{
					comboBoxCtlgLanguages.Items.Add("All Languages");
				}

				// now fill the catalog languages
				foreach(DataRow dr in catLanguages.Tables[0].Rows)
				{
					DataRow[] row = Languages.Tables[0].Select("culture_name='"+dr["Language"].ToString()+"'");
					comboBoxCtlgLanguages.Items.Add(row[0]["display_name"].ToString());
				}

				comboBoxCtlgLanguages.SelectedIndex = 0;
			}

			// get the vendors

		}

		private void btnVendorSelectorCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void btnVendorSelectorOk_Click(object sender, System.EventArgs e)
		{
			// send the catlaog
			this.Close();
		}
	}
}
